#ifndef _APPS_BDESKTOP_CTOPBAR_H_
#define _APPS_BDESKTOP_CTOPBAR_H_

#include "auto.h"
#include <buola/gui/cwindow.h>
#include <buola/gui/caccelerator.h>
#include <buola/widgets/cbutton.h>
#include <buola/gui/cmenu.h>
#include <buola/os/cappmenu.h>

namespace buola { namespace bdesktop {

class CTopBar : public gui::CWindow
{
public:
    CTopBar();
    ~CTopBar();
    
    void AddItem(CTopBarItem *pItem);
    void RemoveItem(CTopBarItem *pItem);
    CTopBarItem *FindItemAt(const CPoint &pPoint);

protected:

////////////// event handling //////////////
    virtual void OnCreate();
    virtual void OnButtonDown(gui::CMouseEvent*);
    virtual void OnMouseMove(gui::CMouseEvent*);
    virtual void OnMouseOut(gui::CMouseEvent*);
    virtual void OnPreExpose();
    virtual void OnExpose(gui::CExposeEvent*);
    virtual void OnSize(gui::CGeometryEvent*);
    virtual void OnKeyDown(gui::CKeyEvent *pE);

    void OnAppMenu();
    void OnPlacesMenu();

protected:
    gui::CAccelerator mAltF1;

    std::vector<CTopBarItem*> mItems;
    bool mMouseInside;
    CPoint mMousePos;

    double mHeight;
    double mTotalHeight;

    bool mPosValid;

    CTextItem *mAppMenuItem;
    CTextItem *mPlacesMenuItem;

    os::CAppMenu *mMIMEMenu;
    gui::PMenu mAppMenu;
};

/*namespace bdesktop*/ } /*namespace buola*/ }

#endif
